cd "C:\Users\alen_\Dropbox\burning_glass\data"

*** Use ACS to study UWP change (Based on home location)


u "2018_2020.dta", clear
append using "2021.dta"
append using "2022.dta"


** drop the remote workers
drop if tranwork==80 | tranwork==0
keep if uhrswork>=35
keep if age>=25 & age<=65
bysort met2013: egen total_perwt=total(perwt)
bysort met2013 occ2010: egen M=total(perwt)
sum incwage
g ln_wage=ln(incwage/(uhrswork*52))
g ln_total_perwt=ln(total_perwt)
g ln_M=ln(M)
drop if met2013==0

merge m:1 occ2010 using soc_occ_crosswalk
keep if _merge==3
drop _merge

g post=0 if year<2020
replace post=1 if year==2020 | year==2021
replace post=1 if year==2022

ren onetsoccode onet
merge m:1 onet using "remote_dummy_based_on_bg"
drop if _merge==2
drop _merge 

g remote=0 if dremote<0.12
replace remote=1 if dremote>=0.165 & dremote<.

* Table 2 
* Column 4
reghdfe ln_wage c.ln_M##i.remote##i.post [w=perwt], absorb(occ2010 i.marst i.race i.hispan i.educ i.sex i.age) cluster(met2013)


* Use ACS-generated remote dummy for regression 

**** 
u "2018_2020.dta", clear
append using "2021.dta"
append using "2022.dta"

** drop the remote workers
drop if tranwork==80 | tranwork==0
keep if uhrswork>=35
keep if age>=25 & age<=65
bysort met2013: egen total_perwt=total(perwt)
bysort met2013 occ2010: egen M=total(perwt)
sum incwage
g ln_wage=ln(incwage/(uhrswork*52))
g ln_total_perwt=ln(total_perwt)
g ln_M=ln(M)
drop if met2013==0

g post=0 if year<2020
replace post=1 if year==2020 | year==2021
replace post=1 if year==2022

merge m:1 occ2010 using "remote_dummy_based_on_acs"
drop if _merge==2
drop _merge 

g remote=0 if dremote<0.06
replace remote=1 if dremote>=0.18 & dremote<.

* Table 2 
* Column 5
reghdfe ln_wage c.ln_M##i.remote##i.post [w=perwt], absorb(occ2010 i.marst i.race i.hispan i.educ i.sex i.age) cluster(met2013)



**** Pre-pandemic commute time 

cd "C:\Users\alen_\Dropbox\burning_glass\data"

*** Use ACS to study UWP change (Based on home location)

u "2019.dta", clear
drop if tranwork==80 | tranwork==0
keep if uhrswork>=35
keep if age>=25 & age<=65

* MANAGEMENT, BUSINESS, SCIENCE, AND ARTS
g occ_group=1 if occ2010>=10 & occ2010<=430
* BUSINESS OPERATIONS SPECIALISTS
replace occ_group=2 if occ2010>=500 & occ2010<=730
* FINANCIAL SPECIALISTS
replace occ_group=3 if occ2010>=800 & occ2010<=950
* COMPUTER AND MATHEMATICAL
replace occ_group=4 if occ2010>=1000 & occ2010<=1240
* ARCHITECTURE AND ENGINEERING
replace occ_group=5 if occ2010>=1300 & occ2010<=1540
* TECHNICIANS
replace occ_group=6 if occ2010>=1550 & occ2010<=1560
* LIFE, PHYSICAL, AND SOCIAL SCIENCE
replace occ_group=7 if occ2010>=1600 & occ2010<=1980
* COMMUNITY AND SOCIAL SERVICES
replace occ_group=8 if occ2010>=2000 & occ2010<=2060
* LEGAL
replace occ_group=9 if occ2010>=2100 & occ2010<=2150
* EDUCATION, TRAINING, AND LIBRARY
replace occ_group=10 if occ2010>=2200 & occ2010<=2550
* ARTS, DESIGN, ENTERTAINMENT, SPORTS, AND MEDIA
replace occ_group=11 if occ2010>=2600 & occ2010<=2920
* HEALTHCARE PRACTITIONERS AND TECHNICAL
replace occ_group=12 if occ2010>=3000 & occ2010<=3540
* HEALTHCARE SUPPORT
replace occ_group=13 if occ2010>=3600 & occ2010<=3650
* PROTECTIVE SERVICE
replace occ_group=14 if occ2010>=3700 & occ2010<=3950
* FOOD PREPARATION AND SERVING
replace occ_group=15 if occ2010>=4000 & occ2010<=4150
* BUILDING AND GROUNDS CLEANING AND MAINTENANCE
replace occ_group=16 if occ2010>=4200 & occ2010<=4250
* PERSONAL CARE AND SERVICE
replace occ_group=17 if occ2010>=4300 & occ2010<=4650
* SALES AND RELATED
replace occ_group=18 if occ2010>=4700 & occ2010<=4965
* OFFICE AND ADMINISTRATIVE SUPPORT
replace occ_group=19 if occ2010>=5000 & occ2010<=5940
* FARMING, FISHING, AND FORESTRY
replace occ_group=20 if occ2010>=6005 & occ2010<=6130
* CONSTRUCTION
replace occ_group=21 if occ2010>=6200 & occ2010<=6765
* EXTRACTION
replace occ_group=22 if occ2010>=6800 & occ2010<=6940
* INSTALLATION, MAINTENANCE, AND REPAIR
replace occ_group=23 if occ2010>=7000 & occ2010<=7630
* PRODUCTION
replace occ_group=24 if occ2010>=7700 & occ2010<=8965
* TRANSPORTATION AND MATERIAL MOVING
replace occ_group=25 if occ2010>=9000 & occ2010<=9750

collapse pre_trantime=trantime [w=perwt], by(occ_group statefip puma)

save commute_occ_group_2019, replace


u "2019.dta", clear
append using "2020.dta"
append using "2021.dta"
append using "2022.dta"

drop if tranwork==0
keep if uhrswork>=35
keep if age>=25 & age<=65

merge m:1 occ2010 using soc_occ_crosswalk
drop if _merge==2
drop _merge

g post=0 if year<2020
replace post=1 if year==2020 | year==2021
replace post=1 if year==2022

ren onetsoccode onet
merge m:1 onet using "remote_dummy_based_on_bg"
drop if _merge==2
drop _merge 

g remote=0 if dremote<0.12
replace remote=1 if dremote>=0.165 & dremote<.


* MANAGEMENT, BUSINESS, SCIENCE, AND ARTS
g occ_group=1 if occ2010>=10 & occ2010<=430
* BUSINESS OPERATIONS SPECIALISTS
replace occ_group=2 if occ2010>=500 & occ2010<=730
* FINANCIAL SPECIALISTS
replace occ_group=3 if occ2010>=800 & occ2010<=950
* COMPUTER AND MATHEMATICAL
replace occ_group=4 if occ2010>=1000 & occ2010<=1240
* ARCHITECTURE AND ENGINEERING
replace occ_group=5 if occ2010>=1300 & occ2010<=1540
* TECHNICIANS
replace occ_group=6 if occ2010>=1550 & occ2010<=1560
* LIFE, PHYSICAL, AND SOCIAL SCIENCE
replace occ_group=7 if occ2010>=1600 & occ2010<=1980
* COMMUNITY AND SOCIAL SERVICES
replace occ_group=8 if occ2010>=2000 & occ2010<=2060
* LEGAL
replace occ_group=9 if occ2010>=2100 & occ2010<=2150
* EDUCATION, TRAINING, AND LIBRARY
replace occ_group=10 if occ2010>=2200 & occ2010<=2550
* ARTS, DESIGN, ENTERTAINMENT, SPORTS, AND MEDIA
replace occ_group=11 if occ2010>=2600 & occ2010<=2920
* HEALTHCARE PRACTITIONERS AND TECHNICAL
replace occ_group=12 if occ2010>=3000 & occ2010<=3540
* HEALTHCARE SUPPORT
replace occ_group=13 if occ2010>=3600 & occ2010<=3650
* PROTECTIVE SERVICE
replace occ_group=14 if occ2010>=3700 & occ2010<=3950
* FOOD PREPARATION AND SERVING
replace occ_group=15 if occ2010>=4000 & occ2010<=4150
* BUILDING AND GROUNDS CLEANING AND MAINTENANCE
replace occ_group=16 if occ2010>=4200 & occ2010<=4250
* PERSONAL CARE AND SERVICE
replace occ_group=17 if occ2010>=4300 & occ2010<=4650
* SALES AND RELATED
replace occ_group=18 if occ2010>=4700 & occ2010<=4965
* OFFICE AND ADMINISTRATIVE SUPPORT
replace occ_group=19 if occ2010>=5000 & occ2010<=5940
* FARMING, FISHING, AND FORESTRY
replace occ_group=20 if occ2010>=6005 & occ2010<=6130
* CONSTRUCTION
replace occ_group=21 if occ2010>=6200 & occ2010<=6765
* EXTRACTION
replace occ_group=22 if occ2010>=6800 & occ2010<=6940
* INSTALLATION, MAINTENANCE, AND REPAIR
replace occ_group=23 if occ2010>=7000 & occ2010<=7630
* PRODUCTION
replace occ_group=24 if occ2010>=7700 & occ2010<=8965
* TRANSPORTATION AND MATERIAL MOVING
replace occ_group=25 if occ2010>=9000 & occ2010<=9750

merge m:1 occ_group statefip puma using commute_occ_group_2019
drop if _merge==2
drop _merge 

egen puma_id=group(statefip puma)

bysort met2013: egen total_perwt=total(perwt)
bysort met2013 occ2010: egen M=total(perwt)
sum incwage
g ln_wage=ln(incwage/(uhrswork*52))
g ln_total_perwt=ln(total_perwt)
g ln_M=ln(M)
drop if met2013==0

* Table A5
* Column 1
reg ln_wage c.pre_trantime##i.remote##i.post [w=perwt], cluster(puma_id)
* Column 2
reghdfe ln_wage c.pre_trantime##i.remote##i.post [w=perwt], absorb(i.year##i.met2013 i.year##i.sex i.year##i.age i.year##i.educ i.year##i.race i.year##i.hispan i.year##i.marst ) cluster(puma_id)
* Column 3
reg trantime c.pre_trantime##i.remote##i.post [w=perwt], cluster(puma_id)
* Column 4
reghdfe trantime c.pre_trantime##i.remote##i.post [w=perwt], absorb(i.year##i.met2013 i.year##i.sex i.year##i.age i.year##i.educ i.year##i.race i.year##i.hispan i.year##i.marst ) cluster(puma_id)




